import { PageContext } from "./page-context";
import $ from "jquery";

const columns = ["维护时间", "维保人", "维保人工号", "停机时长"];
const rows = [
  ["XXXX-XX-XX", "池剑华", "60218718", "--Hour"],
  ["XXXX-XX-XX", "兰小方", "61228215", "--Hour"],
  ["XXXX-XX-XX", "江世泽", "62238413", "--Hour"],
  ["XXXX-XX-XX", "李民博", "63248114", "--Hour"],
  ["XXXX-XX-XX", "李洪涛", "64258215", "--Hour"],
];

function initMaintenanceTable() {
  const table = $("#maintenance-table");
  // 创建一个thead元素
  const thread = $("<thead></thead>");
  // 创建一个tr元素
  let tr = $("<tr></tr>");
  columns.forEach((columnName) => {
    tr.append($("<th></th>").text(columnName));
  });
  thread.append(tr);

  const tbody = $("<tbody></tbody>");
  rows.forEach((row) => {
    tr = $("<tr></tr>");
    row.forEach((column) => {
      tr.append($("<td></td>").text(column));
    });
    tbody.append(tr);
  });

  table.append(thread, tbody);
}

PageContext.onLoaded(()=>{
    initMaintenanceTable();
});